﻿/**
 * @file lrc.c
 * @brief this is a brief description
 * @details this is the detail description.
 * @author fulong 
 * @data 7/8/2014
 * @version 1.0
 * @par Copyright (c):
 * @par First build
 *     version: fulong 
 *     data: 7/8/2014
 */
#include "lrc.h"
#include "../dev/uart.h"

/*!< 求data的补码 */
#define complemental_code(data) (~(data)+1)

/*! \brief 计算 @see verify_ptr 数组长度为 @see len 的数据的LRC值
 * \param len 所要求LRC的数组的长度
 * \param verify_ptr 所要求LRC的数组
 * \retrun 求得的LRC值.
 */
uint8 get_lrc_verify_num(const uint8 *verify_ptr,uint8 len)
{
    uint8 i;
    uint8 verify_sum=0;
    for (i=0;i<len;i++)
    {
        verify_sum+=verify_ptr[i];
    }
    return complemental_code(verify_sum);
}
